BUILD=build
GENDATA=gendata
STANDARD=standard
BENCHMARK=benchmark
TEST=test
TESTCASES= 1 2 3 4 5 6 7 8 9 10
OBJECTS= $(STANDARD)
CFLAGS = -g -Wall -Wno-unused-result -O3
CC=cc
CXX=c++

$(BUILD): $(OBJECTS)

$(STANDARD): src/standard.c
	$(CC) $(CFLAGS) src/standard.c -o bin/standard

$(TEST):
	-rm tmp.out
	for i in $(TESTCASES); do \
		python3 src/fast.py < data/data$$i.in > tmp.out; \
		diff tmp.out data/data$$i.out; \
		echo $$i ok; \
	done
	-rm tmp.out

$(GENDATA): src/gendata.py
	-rm data/*
	for i in $(TESTCASES); do \
		python3 src/gendata.py > data/data$$i.in; \
		bin/standard < data/data$$i.in > data/data$$i.out; \
		echo $$i done; \
	done

.PHONY: clean

clean:
	-rm bin/benchmark
	-rm -rf bin/benchmark.dSYM
	-rm bin/standard
	-rm -rfv bin/standard.dSYM
